<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1>当前是第<span id="num">1</span>页</h1>
<a href="list.html?a=1">1</a>
<a href="list.html?a=2">2</a>
<a href="list.html?a=3">3</a>
<a href="list.html?a=4">4</a>
<a href="list.html?a=5">5</a>
<script>
    window.onload = function () {
        var par = location.search;
        if (par == ''){
            par = '1';
        }
        document.getElementById('num').innerHTML = par;
        var as = document.getElementsByTagName('a');
        console.log(as);
        for(var i = 0,len = as.length;i<len;i++){
            (function(j){
                as[j].onclick = function(){
                    var href = as[j].href;
                    console.log(href);
                    location.replace(href);//assign
                }
            })(i);
        }
    }
</script>
</body>
</html>